/**
 * Author: Dmitry Ustimov
 * Date: 5/14/13
 * Time: 10:06 PM
 */

package com.gmail.dmitryustimov.ms.java7.mediator.classic.example.classic_example3;

import java.util.ArrayList;
import java.util.List;

public class FacebookGroupMediator {

    List<Receiver> receiverList = new ArrayList<>();

    public void signOn(Receiver receiver) {
        receiverList.add(receiver);
    }

    public void block(Receiver receiver) {
        receiverList.remove(receiver);
    }

    public void unblock(Receiver receiver) {
        receiverList.add(receiver);
    }

    // Send is implemented as a broadcast
    public void send(String message, String from) {
        for (Receiver receiver: receiverList) {
            receiver.receive(message, from);
        }
        System.out.println();
    }
}
